package 回溯;

import java.util.*;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 字母大小写全排列784.java
 * @createTime 2023年02月08日 19:21:00
 */
public class 字母大小写全排列784 {
	Set<String> result = new HashSet<>();

	public static   void main(String[] args) {
		System.out.println(tidsToStr("10230210-328020806601481|20230210-328020806601481"));;
	}

	public static String tidsToStr(String tids) {
		//跨境托管订单
		if (tids.contains("FPS")){
			return tids;
		}
		String[] tidArr = tids.split("\\|");
		Map<Long, String> tidMap = new HashMap<>();
		for (int i = 0; i < tidArr.length; i++) {
			String tid = tidArr[i].split(":")[0];
			Long key = Long.valueOf(tid.split("-")[1]);
			tidMap.put(key, tid);

		}
		StringBuffer result = new StringBuffer();

		Object[] array = tidMap.keySet().toArray();
		Arrays.sort(array);
		for (int j = 0; j < array.length; j++) {
			String tid = tidMap.get(array[j]);
			result.append(tid);
			if (j < array.length - 1) {
				result.append("|");
			}
		}
		return result.toString();
	}

	public  List<String> letterCasePermutation(String s) {
		backTrace(s.toCharArray(), 0);
		return new ArrayList<>(result);
	}

	public  void backTrace(char[] chars, int index) {
		//结束条件
		if (chars.length == index) {
			result.add(new String(chars));
			return;
		}
		for (int i = index; i < chars.length; i++) {
			//校验是不是字母
			char c = chars[i];
			backTrace(chars, i+1);
			//如果是小写
			if (c >= 'a' && c <= 'z') {
				chars[i] = Character.toUpperCase(c);
			} else if (c >= 'A' && c <= 'Z') {
				chars[i] = Character.toLowerCase(c);
			}
			backTrace(chars,i+1);
		}
	}
}
